<template>
    <div class="app-container">

        <el-form class="lookForm" :model="queryParams" ref="queryForm" size="mini" :inline="true" label-width="140px">
            <el-form-item label="岗位名称" prop="postName">
                <el-input v-model="queryParams.postName" placeholder="请输入岗位名称" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="设岗部门" prop="deptName">
                <el-input v-model="queryParams.deptName" placeholder="请输入设岗部门" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="负责人姓名" prop="fzrName">
                <el-input v-model="queryParams.fzrName" placeholder="请输入负责人姓名" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <!-- <el-form-item label="指导老师姓名" prop="zdlsName">
                <el-input v-model="queryParams.zdlsName" placeholder="请输入指导老师姓名" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item> -->
            <el-form-item label="校区" prop="campusName">
                <el-input v-model="queryParams.campusName" placeholder="请输入校区" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="工作地点" prop="workAddr">
                <el-input v-model="queryParams.workAddr" placeholder="请输入工作地点" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="申请时间" prop="applyTime">
                <el-date-picker clearable v-model="queryParams.applyTime" type="date" value-format="yyyy-MM-dd"
                    placeholder="请选择申请时间">
                </el-date-picker>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button type="success" plain icon="el-icon-finished" size="mini"
                    @click="manyAudit('3')">批量同意</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="danger" plain icon="el-icon-close" size="mini"
                    @click="manyAudit('10')">批量拒绝</el-button>
            </el-col>

            <el-col :span="3">
                <el-badge :value="changeTotal" class="item">
                    <el-button type="primary" plain icon="el-icon-check" size="mini" @click="lookChangeVClick">
                        点我审核 申请修改
                        岗位的设岗人数
                        记录</el-button>
                </el-badge>
            </el-col>
        </el-row>

        <el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" />
            <el-table-column label="岗位名称" align="center" prop="postName" />
            <el-table-column label="设岗部门" align="center" prop="deptName" />
            <el-table-column label="设岗人数" align="center" prop="postCount" />
            <el-table-column label="审核状态" align="center" prop="applyStatus">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.qgzx_apply_status" :value="scope.row.applyStatus" />
                </template>
            </el-table-column>
            <el-table-column label="申请时间" align="center" prop="applyTime" width="180">
                <template slot-scope="scope">
                    <span>{{ parseTime(scope.row.applyTime) }}</span>
                </template>
            </el-table-column>

            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" icon="el-icon-view" @click="lookVClick(scope.row)">审核</el-button>
                </template>
            </el-table-column>
        </el-table>

        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize" @pagination="getList" />



        <el-dialog title="岗位审核" :visible.sync="lookV" append-to-body fullscreen>
            <el-form class="lookForm" size="mini" ref="applyForm" label-width="148px">
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="岗位名称" prop="postName">
                            <el-input v-model="lookForm.postName" readonly />
                        </el-form-item>
                    </el-col>

                    <el-col :span="8">
                        <el-form-item label="设岗部门" prop="deptId">
                            <el-input v-model="lookForm.deptName" readonly />
                        </el-form-item>
                    </el-col>

                    <el-col :span="8">
                        <el-form-item label="设岗人数" prop="postCount">
                            <el-input v-model="lookForm.postCount" readonly />
                        </el-form-item>
                    </el-col>

                    <el-col :span="8">
                        <el-form-item label="负责人" prop="fzrName">
                            <el-input v-model="lookForm.fzrName" readonly />
                        </el-form-item>
                    </el-col>

                    <!-- <el-col :span="8">
                        <el-form-item label="指导老师" prop="zdlsName">
                            <el-input v-model="lookForm.zdlsName" readonly />
                        </el-form-item>
                    </el-col> -->

                    <el-col :span="8">
                        <el-form-item label="联系电话" prop="zdlsPhone">
                            <el-input v-model="lookForm.zdlsPhone" readonly />
                        </el-form-item>
                    </el-col>

                    <el-col :span="8">
                        <el-form-item label="付酬方式">
                            <el-input value="按小时" disabled />
                        </el-form-item>
                    </el-col>

                    <el-col :span="8">
                        <el-form-item label="付酬标准">
                            <el-input value="15.00" disabled />
                        </el-form-item>
                    </el-col>

                    <el-col :span="8">
                        <el-form-item label="预计金额(元/月/人)" prop="willMoney">
                            <el-input v-model="lookForm.willMoney" readonly />
                        </el-form-item>
                    </el-col>

                    <el-col :span="12">
                        <el-form-item label="预计金额合计(元/月)" prop="willMoneyTotal">
                            <el-input readonly v-model="lookForm.willMoneyTotal" />
                        </el-form-item>
                    </el-col>

                    <el-col :span="24">
                        <el-form-item label="岗位职责" prop="workNeed">
                            <el-input type="textarea" v-model="lookForm.workNeed" readonly />
                        </el-form-item>
                    </el-col>


                    <el-col :span="24">
                        <el-form-item label="技能要求" prop="skillNeed">
                            <el-input type="textarea" v-model="lookForm.skillNeed" readonly />
                        </el-form-item>
                    </el-col>

                    <el-col :span="24">
                        <el-form-item label="每周工作时长" prop="weekTime">
                            <el-input v-model="lookForm.weekTime" readonly />
                        </el-form-item>
                    </el-col>

                    <el-col :span="8">
                        <el-form-item label="校区" prop="campusName">
                            <el-input v-model="lookForm.campusName" readonly />
                        </el-form-item>
                    </el-col>

                    <el-col :span="16">
                        <el-form-item label="工作地点" prop="workAddr">
                            <el-input v-model="lookForm.workAddr" readonly />
                        </el-form-item>
                    </el-col>

                    <el-col :span="8">
                        <el-form-item label="岗位类型" prop="postType">
                            <el-input v-model="lookForm.postType" readonly />
                        </el-form-item>
                    </el-col>

                    <el-col :span="8">
                        <el-form-item label="备注" prop="remark">
                            <el-input v-model="lookForm.remark" readonly />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="申请理由" prop="applyReason">
                            <el-input type="textarea" v-model="lookForm.applyReason" readonly />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="审核状态" prop="applyReason">
                            <dict-tag :options="dict.type.qgzx_apply_status" :value="lookForm.applyStatus" />
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <hr />
            <el-steps :active="getStep(lookForm)">
                <el-step title="部门制表人申请岗位" description=""></el-step>
                <el-step title="部门领导审批" :status="isEmpty(lookForm.deptCmt) ? 'wait' : getStepStatus(lookForm.deptCmt)"
                    :description="isEmpty(lookForm.deptCmt) ? '' : lookForm.deptCmt"></el-step>
                <el-step title="资助办领导审批" :status="isEmpty(lookForm.highCmt) ? 'wait' : getStepStatus(lookForm.highCmt)"
                    :description="isEmpty(lookForm.highCmt) ? '' : lookForm.highCmt"></el-step>
            </el-steps>
            <hr />
            <el-form label-width="148px" size="mini">
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="部门意见">
                            <el-radio-group v-model="lookForm.deptCmt" disabled>
                                <el-radio :label="'同意'">同意</el-radio>
                                <el-radio :label="'拒绝'">拒绝</el-radio>
                                <el-radio :label="'驳回'">驳回</el-radio>
                            </el-radio-group>
                        </el-form-item>
                        <el-form-item label="部门签章">
                            <img :src="baseurl + lookForm.deptSign" width="200px" height="50px">
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="资助办意见">
                            <el-radio-group v-model="lookForm.highCmt">
                                <el-radio :label="'同意'">同意</el-radio>
                                <el-radio :label="'拒绝'">拒绝</el-radio>
                                <el-radio :label="'驳回'">驳回</el-radio>
                            </el-radio-group>
                        </el-form-item>
                        <el-form-item label="资助办签章">
                            <el-upload :limit="1" class="avatar-uploader" :file-list="upload.fileList"
                                :action="upload.url" :headers="upload.headers" :show-file-list="false"
                                :on-success="handleAvatarSuccess">
                                <img v-if="lookForm.highSign" :src="baseurl + lookForm.highSign" width="200px"
                                    height="50px" class="avatar">
                                <span v-else> 点击上传</span>
                            </el-upload>
                        </el-form-item>
                        <el-form-item label=" ">
                            <el-button @click="doAudit" type="success" plain>审核</el-button>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </el-dialog>


        <el-dialog :visible.sync="lookChangeV" title="审核 申请 修改岗位的设岗人数 记录" append-to-body fullscreen>
            <el-table v-loading="changeLoading" :data="changeTableData">
                <el-table-column label="#" align="center" prop="id" />
                <el-table-column label="岗位名称" align="center" prop="postName" />
                <el-table-column label="修改的设岗人数" align="center" prop="newCount" />
                <el-table-column label="审核状态" align="center" prop="applyStatus">
                    <template slot-scope="scope">
                        <dict-tag :options="dict.type.qgzx_apply_status" :value="scope.row.applyStatus" />
                    </template>
                </el-table-column>
                <el-table-column label="申请时间" align="center" prop="applyTime" width="180">
                    <template slot-scope="scope">
                        <span>{{ parseTime(scope.row.applyTime) }}</span>
                    </template>
                </el-table-column>

                <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                    <template slot-scope="scope">
                        <el-button size="mini" type="text" icon="el-icon-view"
                            @click="changeAuditVClick(scope.row)">审核</el-button>
                    </template>
                </el-table-column>
            </el-table>

            <pagination v-show="changeTotal > 0" :total="changeTotal" :page.sync="changeQueryParams.pageNum"
                :limit.sync="changeQueryParams.pageSize" @pagination="getChangeList" />
        </el-dialog>


        <el-dialog :visible.sync="changeAuditV" title="审核" append-to-body :close-on-click-modal="false">
            <el-form class="lookForm" size="mini" ref="changeForm" label-width="148px">
                <el-form-item label="设岗部门">
                    <el-input v-model="changeForm.deptName" readonly />
                </el-form-item>
                <el-form-item label="岗位名称">
                    <el-input v-model="changeForm.postName" readonly />
                </el-form-item>
                <el-form-item label="当前在岗人数">
                    <el-input v-model="changeForm.inCount" readonly />
                </el-form-item>
                <el-form-item label="修改后的设岗人数" prop="newCount">
                    <el-input v-model="changeForm.newCount" readonly />
                </el-form-item>
                <el-form-item label="申请理由" prop="applyReason">
                    <el-input type="textarea" v-model="changeForm.applyReason" readonly />
                </el-form-item>
            </el-form>
            <hr />
            <el-form label-width="148px" size="mini">

                <el-form-item label="资助办意见">
                    <el-radio-group v-model="changeAuditForm.highCmt">
                        <el-radio :label="'同意'">同意</el-radio>
                        <el-radio :label="'拒绝'">拒绝</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="资助办签章">
                    <el-upload :limit="1" class="avatar-uploader" :file-list="upload.fileList" :action="upload.url"
                        :headers="upload.headers" :show-file-list="false" :on-success="handleAvatarSuccess">
                        <img v-if="changeAuditForm.highSign" :src="baseurl + changeAuditForm.highSign" width="200px"
                            height="50px" class="avatar">
                        <span v-else> 点击上传</span>
                    </el-upload>
                </el-form-item>
                <el-form-item label=" ">
                    <el-button @click="doChangeAudit" type="success" plain>审核</el-button>
                </el-form-item>

            </el-form>
        </el-dialog>


    </div>
</template>
<script>

import { cancelApply, doApply, doAudit, doSave, getOwnSign, listHigh as listOwnApply, manyAudit } from "@/api/workstudy/post";

import { fullLoading, isEmpty } from "@/api/helpFunc";

import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";

import { noAuthList as listDept } from "@/api/system/dept";

import TeacherSelect from '@/views/components/TeacherSelect/index';

import { getUserProfile } from "@/api/system/user";

import { getToken } from "@/utils/auth";

import { doAudit as doChangeAudit, listHigh as getChangeList } from "@/api/workstudy/change";
import { countStuPostInByPostId } from "@/api/workstudy/stuPost";

export default {
    name: "workstudy-apply",
    components: { Treeselect, TeacherSelect },
    dicts: ['qgzx_apply_status'],
    data() {
        return {
            isEmpty,
            loading: false,
            total: 0,
            tableData: [],

            queryParams: {
                pageNum: 1,
                pageSize: 10,
                postName: null,
            },

            applyV: false,
            applyForm: {

            },

            lookV: false,
            lookForm: {},


            deptOptions1: [],
            rules: {
                postName: [
                    { required: true, message: "岗位名称不能为空", trigger: "blur" }
                ],
                postCount: [
                    { required: true, message: "设岗人数不能为空", trigger: "blur" }
                ],
                zdlsPhone: [
                    { required: true, message: "不能为空", trigger: "blur" }
                ],
                willMoney: [
                    { required: true, message: "不能为空", trigger: "blur" }
                ],
                willMoneyTotal: [
                    { required: true, message: "不能为空", trigger: "blur" }
                ],
                workNeed: [
                    { required: true, message: "不能为空", trigger: "blur" }
                ],
                skillNeed: [
                    { required: true, message: "不能为空", trigger: "blur" }
                ],
                weekTime: [
                    { required: true, message: "不能为空", trigger: "blur" }
                ],
                campusName: [
                    { required: true, message: "不能为空", trigger: "change" }
                ],
                workAddr: [
                    { required: true, message: "不能为空", trigger: "blur" }
                ],
                postType: [
                    { required: true, message: "不能为空", trigger: "change" }
                ],
                applyReason: [
                    { required: true, message: "不能为空", trigger: "blur" }
                ],
            },

            upload: {
                headers: { Authorization: "Bearer " + getToken() },
                // 上传的地址
                url: process.env.VUE_APP_BASE_API + "/common/upload",
                fileList: []
            },
            baseurl: process.env.VUE_APP_BASE_API + "/",

            selectedId: [],


            lookChangeV: false,
            changeLoading: false,
            changeTotal: 0,
            changeTableData: [],

            changeQueryParams: {
                pageNum: 1,
                pageSize: 10,
            },


            changeAuditV: false,
            changeForm: {},
            changeAuditForm: {}
        }

    },
    watch: {
        "applyForm.postCount"(newValue, oldValue) {
            if (newValue != 0 && !isEmpty(newValue)) {
                if (this.applyForm.willMoney != 0 && !isEmpty(this.applyForm.willMoney)) {
                    this.applyForm.willMoneyTotal = newValue * this.applyForm.willMoney;
                }
            }
        },
        "applyForm.willMoney"(newValue, oldValue) {
            if (newValue != 0 && !isEmpty(newValue)) {
                if (this.applyForm.postCount != 0 && !isEmpty(this.applyForm.postCount)) {
                    this.applyForm.willMoneyTotal = newValue * this.applyForm.postCount;
                }
            }
        },

    },
    created() {
        this.getList();
        this.initDept();
        this.getUserProfile();
        this.getChangeList();

    },
    methods: {
        //此方法用于判断步骤条当前步骤的状态
        getStepStatus(data) {
            if (data == "同意") {
                return 'success';
            } else {
                return 'error';
            }
        },

        //此方法用于判断步骤条到哪个步骤了
        getStep(data) {
            if (!isEmpty(data.highCmt)) { //判断资助办领导有没有审批
                return 3;
            } else if (!isEmpty(data.deptCmt)) { //判断部门领导有没有审批
                return 2;
            } else {
                return 1;
            }
        },
        async doChangeAudit() {
            console.log(this.changeAuditForm);
            let sdata = { ...this.changeAuditForm };

            if (isEmpty(sdata.highCmt)) {
                this.$message.info("请选择资助办意见");
                return;
            }
            if (isEmpty(sdata.highSign)) {
                this.$message.info("请上传资助办签章");
                return;
            }

            if (sdata.highCmt == '同意') {
                sdata.applyStatus = '3';
            } else {
                sdata.applyStatus = "10"; //拒绝
            }

            let loading = fullLoading(this);
            let res = await doChangeAudit(sdata);
            loading.close();
            if (res.code == 200) {
                this.getChangeList();
                this.$message.success(res.msg);
                this.changeAuditV = false;
            }

        },

        async changeAuditVClick(row) {
            this.changeForm = {};

            let loading = fullLoading(this);
            let res = await getOwnSign();
            loading.close();
            if (res.code == 200) {
                let data = { ...res.data };
                if (isEmpty(data.signature)) {
                    this.$confirm('您的签名尚未上传', '提示', {
                        confirmButtonText: '点我前往',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        this.$router.push("/user/profile")
                    }).catch(() => {

                    });
                } else {
                    this.changeAuditForm.highSign = data.signature;

                    let loading1 = fullLoading(this);
                    let res1 = await countStuPostInByPostId(row.postId); //获取岗位在岗人数
                    loading1.close();
                    if (res1.code == 200) {
                        let data = { ...res1.data };
                        let stuPostCount = data.count;
                        this.changeForm.deptName = row.deptName;
                        this.changeForm.postName = row.postName;
                        this.changeForm.inCount = stuPostCount;
                        this.changeForm.applyReason = row.applyReason;
                        this.changeForm.newCount = row.newCount;
                        this.changeAuditForm.id = row.id;
                        this.changeAuditV = true;
                    }
                }
            }



        },


        //查询修改岗位设岗人数申请记录
        async getChangeList() {
            this.changeLoading = true;
            let res = await getChangeList(this.changeQueryParams);
            this.changeLoading = false;
            if (res.code == 200) {
                this.changeTableData = [...res.rows];
                this.changeTotal = res.total;
            }
        },

        lookChangeVClick() {
            this.lookChangeV = true;
            this.getChangeList();
        },


        handleSelectionChange(val) {
            this.selectedId = val.map(x => x.id);
        },
        async manyAudit(val) {
            if (isEmpty(this.selectedId)) {
                this.$message.info("请勾选记录");
                return;
            }

            let loading = fullLoading(this);
            let res1 = await getOwnSign();
            loading.close();
            if (res1.code == 200) {
                let data = { ...res1.data };
                if (isEmpty(data.signature)) {
                    this.$confirm('您的签名尚未上传', '提示', {
                        confirmButtonText: '点我前往',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        this.$router.push("/user/profile")
                    }).catch(() => {

                    });
                } else {
                    let msg = "";
                    if (val == '3') {
                        msg = "同意";
                    } else {
                        msg = "拒绝";
                    }
                    let sign = data.signature;

                    this.$confirm('您确定要批量' + msg + '吗?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(async () => {
                        let sdata = [];
                        this.selectedId.map(x => {
                            let temp = {
                                id: x,
                                applyStatus: val,
                                highCmt: msg,
                                highSign: sign
                            }
                            sdata.push(temp);
                        });

                        let loading = fullLoading(this);
                        let res = await manyAudit(sdata);
                        loading.close();
                        if (res.code == 200) {
                            this.$message.success(res.msg);
                            this.getList();
                        }
                    }).catch(() => {

                    });


                }
            }

        },
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
            this.getChangeList();
        },
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
            this.getChangeList();
        },
        async doAudit() {
            let sdata = { ...this.lookForm };
            if (isEmpty(sdata.highCmt)) {
                this.$message.info("请选择部门意见");
                return;
            }
            if (isEmpty(sdata.highSign)) {
                this.$message.info("请上传部门签章");
                return;
            }

            if (sdata.highCmt == '驳回') {
                sdata.applyStatus = "11"; //驳回
                this.$prompt('请输入驳回原因', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    inputPattern: /\S/,
                    inputErrorMessage: '请填写'
                }).then(async ({ value }) => {
                    sdata.returnMsg = value;

                    let loading = fullLoading(this);
                    let res = await doAudit(sdata);
                    loading.close();
                    if (res.code == 200) {
                        this.getList();
                        this.$message.success(res.msg);
                        this.lookV = false;
                    }

                }).catch(() => {

                });
            } else {
                if (sdata.highCmt == '同意') {
                    sdata.applyStatus = '3';
                } else {
                    sdata.applyStatus = "10"; //拒绝
                }
                let loading = fullLoading(this);
                let res = await doAudit(sdata);
                loading.close();
                if (res.code == 200) {
                    this.getList();
                    this.$message.success(res.msg);
                    this.lookV = false;
                }
            }
        },
        handleAvatarSuccess(response, file, fileList) {
            this.lookForm.highSign = response.fileName;
            this.upload.fileList = [];
            this.$forceUpdate();
        },
        async lookVClick(row) {
            this.lookForm = {};
            this.lookForm = { ...row };

            let loading = fullLoading(this);
            let res = await getOwnSign();
            loading.close();
            if (res.code == 200) {
                let data = { ...res.data };
                if (isEmpty(data.signature)) {
                    this.$confirm('您的签名尚未上传', '提示', {
                        confirmButtonText: '点我前往',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        this.$router.push("/user/profile")
                    }).catch(() => {

                    });
                } else {
                    this.lookForm.highSign = data.signature;
                    this.lookV = true;
                }
            }

        },
        async doEdit(row) {
            this.applyForm = { ...row };
            this.applyV = true;
        },
        cancelApply(row) {
            let id = row.id;
            this.$confirm('您确定要取消该岗位的申请吗, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(async () => {
                let loading = fullLoading(this);
                let res = await cancelApply(id);
                loading.close();
                if (res.code == 200) {
                    this.$message.success(res.msg);
                    this.getList();
                }
            }).catch(() => {

            });
        },
        async getList() {
            this.loading = true;
            let res = await listOwnApply(this.queryParams);
            this.loading = false;
            if (res.code == 200) {
                this.tableData = [...res.rows];
                this.total = res.total;
            }
        },
        async doApply() {
            this.$refs["applyForm"].validate(async (valid) => {
                if (valid) {
                    let sdata = { ...this.applyForm };
                    let loading = fullLoading(this);
                    let res = await doApply(sdata);
                    loading.close();
                    if (res.code == 200) {
                        this.getList();
                        this.$message.success(res.msg);
                        this.applyV = false;
                    }
                } else {
                    return false;
                }
            });

        },
        async doSave() {
            this.$refs["applyForm"].validate(async (valid) => {
                if (valid) {
                    let sdata = { ...this.applyForm };
                    let loading = fullLoading(this);
                    let res = await doSave(sdata);
                    loading.close();
                    if (res.code == 200) {
                        this.getList();
                        this.$message.success(res.msg);
                        this.applyV = false;
                    }
                } else {
                    return false;
                }
            });
        },
        async getUserProfile() {
            let res = await getUserProfile();
            if (res.code == 200) {
                if (!isEmpty(res.data)) {
                    this.applyForm.deptId = res.data.deptId;
                }
            }
        },
        normalizer(node) {
            if (node.children && !node.children.length) {
                delete node.children;
            }
            return {
                id: node.deptId,
                label: node.deptName,
                children: node.children,
            };
        },
        async initDept() {
            let res = await listDept();
            if (res.code == 200) {
                this.deptOptions1 = this.handleTree(res.data, "deptId");
            }
        },
    }
}


</script>
<style scoped lang="scss">
.lookForm {
    .el-form-item {
        margin-bottom: 5px;
    }
}
</style>